﻿using System;

namespace SoftSource.Common
{
    public static class DateTimeExtensions
    {
        public static DateTime StartOfWeek(this DateTime currentDate, DayOfWeek startOfWeek)
        {
            int diff = currentDate.DayOfWeek - startOfWeek;
            if (diff < 0)
            {
                diff += 7;
            }

            return currentDate.AddDays(-1 * diff).Date;
        }
    } 
}
